from re import S, T
from numpy import square
from manimlib import *
#75cfb8
#bbdfc8
#f0e5d8
#ffc478
class p1(Scene):
    def construct(self):
        # self.add(NumberPlane())
        frame = self.camera.frame
        # self.play(frame.animate.set_width(16))
        side=3
        r=(3*np.sqrt(2)+2)/7*side
        s=Square(side)
        arc1=Arc(0,PI,radius=side/2).next_to(s,UP,buff=0)
        arc2=Arc(1.5*PI,PI,radius=side/2).next_to(s,RIGHT,buff=0)
        v=VGroup(s,arc1,arc2).rotate_about_origin(PI/4)
        c=Circle(radius=r).shift(UP*(r-np.sqrt(2)/2*side))
        self.add(v,c)
        self.wait()
class p2(Scene):
    def construct(self):
        # self.add(NumberPlane())
        frame = self.camera.frame
        # self.play(frame.animate.set_width(16))
        side=3
        r=(3*np.sqrt(2)+2)/7*side
        s=Square(side)
        arc1=Arc(0,PI,radius=side/2).next_to(s,UP,buff=0)
        arc2=Arc(1.5*PI,PI,radius=side/2).next_to(s,RIGHT,buff=0)
        v=VGroup(s,arc1,arc2).rotate_about_origin(PI/4)
        c=Circle(radius=r).shift(UP*(r-np.sqrt(2)/2*side))
        self.add(v,c)
        #
        o=c.get_arc_center()[0]
        o1=arc1.get_arc_center()[0]
        self.add(Line(UP*r,DOWN*r).move_to(o))
        line=Line(o,o1).scale(r/(r-side/2)).next_to(o,UL,buff=0)
        self.add(line,Tex('O').next_to(o,RIGHT),Tex('O_1').next_to(o1,DOWN),Tex('P').next_to(line,UL))
        q=[0,side/2*np.sqrt(2),0]
        self.add(Tex('Q').next_to(q,RIGHT),Polygon(o,o1,q).set_fill('#75cfb8',1))
        self.wait()